package control;


import java.util.HashMap;
/**
 * PADRÂO DE PROJETO COMAND
 */
public class Processador {

    private static final HashMap comandos = new HashMap();

    static {
       
        comandos.put("0", "view.InterfaceLogin");//OK
        comandos.put("1", "view.InterfaceCadastrarUsuario");//OK
        comandos.put("2", "view.InterfacePesquisarMusica");
        comandos.put("3", "view.InterfaceCreditarConta");//OK
        comandos.put("4", "view.InterfaceComprarMusica");//OK
        comandos.put("5", "view.InterfaceCriarPlaylist");//OK
        comandos.put("6", "view.InterfaceGerenciarPlaylist");//OK
        comandos.put("7", "view.InterfaceVerPlaylist");//OK
        comandos.put("8", "view.InterfaceBaixarMusica");//OK
        comandos.put("9", "view.InterfaceTornarseArtista");//OK
        comandos.put("11", "view.InterfaceGerenciarArtista");
        comandos.put("12", "view.InterfaceCriarAlbum");//OK
        comandos.put("13", "view.InterfaceGerenciarAlbum");//OK
        comandos.put("14", "view.InterfaceCriarMusica");//OK
        comandos.put("15", "view.InterfaceDebitarSaldo");//OK
        comandos.put("19", "view.InterfaceImprimirInformacoes");//OK
        comandos.put("20", "view.InterfaceLogout");//OK
        comandos.put("50", "view.InterfaceSair");//OK
    }
 
    public static void direcionar(String cmd) {
        String actionClass = (String) comandos.get(cmd);
        //Cria a instância da classe utilizando introspecção
        try {
            Class classe = Class.forName(actionClass);
            Comando comando = (Comando) classe.newInstance();
            comando.executar();
        } catch (ClassNotFoundException ex) {
            System.out.println(ex);
        } catch (InstantiationException iex) {
            System.out.println(iex);
        } catch (IllegalAccessException iaex) {
            System.out.println(iaex);
        }
    }
}

